import os

from my_json import download_json, save_json, load_json, bulid_download_path
from spider_url import major_detail_json_url

basic_path = str(os.path.dirname(__file__)) + "/"
download_path = bulid_download_path(basic_path)
special_id_path = basic_path + "../basic_info/special_id.json"


def init():
    url = major_detail_json_url()
    special_id = load_json(special_id_path)
    d = {}
    for k, v in special_id.items():
        major0 = download_json(url.to_string(k), download_path + "special_" + str(k) + ".json")
        if k in d:
            raise ValueError("major detail duplicate key")
        d[k] = major0["data"]
    save_json(basic_path + "major.json", d)


init()
